﻿package framework.core;

/**
 * Creation date: (2003-08-28)
 * @author: adminnistrator
 * 数据库字段类
 */
public class Field 
{
	private String  m_name;                  // 字段名
	private int  	m_type;                  // 数据类型
	private boolean m_primary;               // 是否是主键
	private int     m_len ;                  // 字符窜类型最大长度
	private boolean m_null;                  // 是否可以为空
	private Values  m_values = new Values(); // 枚举值
	private String  m_comment;               // 字段显示名 

	//public Field(String name,int type,boolean isPrimary,boolean canNull)
	//{
	//	this(name,type,isPrimary,canNull,-1);
	//}
	
	public Field(String name,int type,boolean isPrimary,boolean canNull,int len,String comment)
	{
		m_name = name;
		m_type = type;
		m_primary = isPrimary;
		m_null = canNull;
		m_len = len ;
		m_comment = comment ;
	}
	
	public void addEnumValue(Value v)
	{
		m_values.add(v);
	}
	public void addEnumValue(double v)
	{
		addEnumValue(new Value(v));
	}
	public void addEnumValue(int v)
	{
		addEnumValue(new Value(v));
	}
	public void addEnumValue(String v)
	{
		addEnumValue(new Value(v));
	}
	
	public boolean canNull()
	{
		return m_null;
	}
	public int getEnumCount()
	{
		return m_values.size();
	}
	public Value getEnumValue(int i)
	{
		return m_values.get(i);
	}
	public int getLen()
	{
		return m_len;
	}
	public String getName()
	{
		return m_name;
	}
	public int getType()
	{
		return m_type;
	}
	public boolean isPrimary()
	{
		return m_primary;
	}
	
	public String getComment()
	{
		return m_comment;
	}
}
